package com.yc.ycbook.read.fragment

import androidx.fragment.app.Fragment
import com.yc.ycbook.R
import com.yc.ycbook.base.BaseFragment
import com.yc.ycbook.common.adapter.CommonPageAdapter
import kotlinx.android.synthetic.main.read_main_fragment.*

/**
 *  阅读的主页
 */
class ReadMainFragment : BaseFragment() {
    companion object {
        fun newInstance(): Fragment {
            return ReadMainFragment()
        }
    }

    private lateinit var mPageAdapter: CommonPageAdapter
    override fun getLayoutId(): Int {
        return R.layout.read_main_fragment
    }

    override fun initView() {
        mPageAdapter = CommonPageAdapter(fragmentManager)
        mPageAdapter.add(ReadBookMarkFragment.newInstance(), "title1")
        mPageAdapter.add(ReadBookMarkFragment.newInstance(), "title2")
        mPageAdapter.add(ReadBookMarkFragment.newInstance(), "title3")
        mPageAdapter.add(ReadBookMarkFragment.newInstance(), "title4")
        mPageAdapter.add(ReadBookMarkFragment.newInstance(), "title5")
        mPageAdapter.add(ReadBookMarkFragment.newInstance(), "title6")
        mPageAdapter.add(ReadBookMarkFragment.newInstance(), "title7")
        mPageAdapter.add(ReadBookMarkFragment.newInstance(), "title8")
        mPageAdapter.add(ReadBookMarkFragment.newInstance(), "title9")
        mPageAdapter.add(ReadBookMarkFragment.newInstance(), "title7")

        readMainVp.adapter = mPageAdapter
        readMainVp.offscreenPageLimit = 3 //设置缓存
        readMainTab.setupWithViewPager(readMainVp)
    }
}